<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

	<title>完善公示信息</title>
	<link rel="stylesheet" href="assets/libs/layui/css/layui.css" />
	<style>
		@media screen and (min-width: 800px) {
			.layui-form-label{
				width: 86px !important;
			}
		}

		.content_box{
			max-width: 960px;    
			display: flex;
    		justify-content: center
		}

		.login-header {
			color: rgba(0, 0, 0, .85) !important;
			padding: 5% 0;
			text-align: center;
		}

		.layui-text em,
		.layui-word-aux {
			color: #ef0909 !important;
			padding: 0 5px !important;
		}

		.layui-input-block {
			margin-left: 0;
			min-height: 46px;
			display: flex;
		}

		.buttongroup {
			display: flex;
			/*justify-content: center;*/
			margin-top: 20%;
		}

		.buttongroup button {
			width: 100%;
			height: 45px;
		}

		.main_content_wrap {
			margin: 20px 0px;
		}

		.layui-form select {
			display: block;
			width: 190px;
			height: 38px;
			padding-right: 30px;
			cursor: pointer;
			border-color: #D2D2D2 !important;
			padding-left: 10px;
		}

		.layui-unselect,
		.layui-form-select {
			display: none;
		}
		.layui-form input[type=radio]{
			display: block;
		}
		.radiobox{
			display: flex !important;
			height: 50px;
    		align-items: center;
		}
		.radiobox input{
			width: 24px;
			height: 24px;
			margin-right: 20px;
			margin-left: 10px;
		}
	</style>
</head>

<body>
	<div class="body">
		<div class="login-header">
			<h2 style="font-weight: 400;letter-spacing: 3px; font-size: 30px">完善公示信息</h2>
		</div>
		<div class="layui-fluid content_box">
			<div class="main_content_wrap">
				<form lay-filter="modifyForm" class="layui-form model-form">
					<div class="layui-form-item">
						<label class="layui-form-label">公示日期</label>
						<div class="layui-input-inline" style="width: 100px;">
							<input type="text" name="show_start_date" placeholder="开始时间" class="layui-input"
								   id='starDate' required autocomplete="off">
						</div>
						<div class="layui-form-mid"> - </div>
						<div class="layui-input-inline" style="width: 100px;">
							<input type="text" name="show_end_date" placeholder="结束时间" class="layui-input"
								   id='endDate' required autocomplete="off">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">联系人</label>
						<div class="layui-input-inline">
							<input name="publicity_user_name" type="text" autocomplete="off" required
								   class="layui-input" />
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">联系电话</label>
						<div class="layui-input-inline">
							<input name="publicity_user_phone" type="text" autocomplete="off" required
								   lay-verify="required|phoneNum" class="layui-input" />
						</div>
					</div>
					<div class="layui-form-item text-center buttongroup">
						<button type="button" lay-filter="modifyFormSubmit" lay-submit
							class="layui-btn site-demo-active">提交</button>
					</div>
				</form>
			</div>
		</div>
	</div>
	<script type="text/javascript" src="assets/libs/layui/layui.js"></script>
	<script type="text/javascript" src="assets/js/config.js"></script>
	<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
	<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>

	<script src="https://wwcdn.weixin.qq.com/node/open/js/wecom-jssdk-1.3.1.js"></script>
	<script src="https://open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js" referrerpolicy="origin"></script>


	<script>
		layui.use(['jquery', 'form', 'layer', 'laydate'], function () {
			var $ = layui.jquery;
			var form = layui.form;
			var layer = layui.layer;
			var laydate = layui.laydate;

			var id = getUrlParam('id');
			var opt_type = getUrlParam('type');
			let userMsg = JSON.parse(localStorage.getItem("userMsg"));

			// 日期范围 - 左右面板独立选择模式
			var startDate = laydate.render({
				elem: '#starDate', //指定元素
				format: 'yyyy-MM-dd', //可任意组合
				trigger: 'click',
				done: function (value, date) {
					endDate.config.min = {
						year: date.year,
						month: date.month - 1, //关键
						date: date.date,
					};
				}
			});
			var endDate = laydate.render({
				elem: '#endDate', //指定元素
				format: 'yyyy-MM-dd', //可任意组合
				trigger: 'click',
				done: function (value, date) {
					startDate.config.max = {
						year: date.year,
						month: date.month - 1,//关键
						date: date.date,
					}
				}

			});

			//监听提交
			form.on('submit(modifyFormSubmit)', function (data) {
				var DISABLED = 'layui-btn-disabled';
				// 增加样式
				$('.site-demo-active').addClass(DISABLED);
				// 增加属性
				$('.site-demo-active').attr('disabled', 'disabled');

				var form_data = data.field;
				form_data.opt_json_content = JSON.stringify(form_data);
				form_data.knowledge_id = id
				form_data.opt_type = opt_type?opt_type:5
				form_data.opt_userid = userMsg.UserId;
				form_data.opt_deptment = Array.isArray(userMsg.department)?userMsg.department.join(','):userMsg.department;
				let newobj = typeChange(form_data);
				$.post(serverUrl + 'Knowledge/modifyInfo.html', newobj, function (res) {
					if (res.success === true) {
						layer.msg('提交成功', { icon: 1, time: 300 }, function () {
							window.location.href = `detail.html?id=`+id;
						});
					} else {
						layer.msg(res.msg, { icon: 2 });
						$('.site-demo-active').removeClass(DISABLED);
						$('.site-demo-active').removeAttr('disabled');
					}
				}, 'json');
				return false;
			});
		});
	</script>
</body>

</html>